package com.bafa.services;

import com.bafa.jdbc.DBAccess;
import com.bafa.objects.Message;

public class ControlPanelServices {

	public static Message updateLeagueName(String name){
		DBAccess db = new DBAccess();
		Message message = new Message();
		try{
			if(!db.retrieveReference("sitename").equalsIgnoreCase(name)){
				db.updateReference("sitename",name);
				message.addMessage("League name successfully updated to "+name);
			}
		}catch(Exception e){
			message.addError("League name could not be updated");
		}finally{
			return message;
		}
	}
	
	public static Message updateTheme(String style) {
		DBAccess db = new DBAccess();
		Message message = new Message();
		try {
			if (!db.retrieveReference("style").equalsIgnoreCase(style+".css")) {
				db
						.updateReference("style", db.retrieveReference(style
								+ "css"));
				db.updateReference("divbackground", db.retrieveReference(style
						+ "divbackground"));
				message.addMessage("Site theme has been updated to " + style);
			}
		} catch (Exception e) {
			message.addError("Site theme could not be updated");
		} finally {
			return message;
		}
	}
}
